package cn.opopopo.design_pattern_learn.行为型.interpreter;

// NOT 表达式
class NotExpression implements Expression {
    private final Expression expression;

    public NotExpression(Expression expression) {
        this.expression = expression;
    }

    @Override
    public boolean interpret(java.util.Map<String, Boolean> context) {
        return !expression.interpret(context);
    }

    @Override
    public String toString() {
        return "NOT " + expression;
    }
}